"use strict";

const Service = require("egg").Service;

class QuestionService extends Service {
    /**
     * 根据问题类型id，获取问题列表
     * @param {*} tid
     */
    async readListByTid(tid) {
        let res = await this.app.mysql.query(
            "select * from question where tid = ?",
            [tid]
        );
        return res;
    }

    async readTypeList() {
        let res = await this.app.mysql.query("select * from question_type");
        return res;
    }

    async add(title, content, tid) {
        let res = await this.app.mysql.query(
            "insert into question (title, content, tid) values (?, ?, ?)",
            [title, content, tid]
        );
        return res;
    }
}

module.exports = QuestionService;
